import { api } from '../index'
import axios from 'axios';



export function addCheckupData(record) {
  return api.post('/checkData', record)
}

const apiClient = axios.create({
  baseURL: 'http://localhost:8080', // 确保与后端端口一致
  timeout: 10000,
  headers: {
    'Content-Type': 'application/json'
  }
});

export function getALLCheckupDataById(id) {
  return apiClient.get(`/checkData/${id}`)
    .then(response => {
      console.log('API响应数据:', response.data);
      return response.data;
    })
    .catch(error => {
      console.error('请求失败:', error);
      throw error; // 将错误传递给调用方
    });
}

export function deleteCheckupData(id) {
  return apiClient.delete(`/checkData/${id}`)
    .then(response => {
      console.log('API响应数据:', response.data);
      return response.data;
    })
    .catch(error => {
      console.error('请求失败:', error);
      throw error; // 将错误传递给调用方
    });
}

export function updateCheckupData(id, record) {
  return apiClient.put(`/checkData/${id}`, record)
    .then(response => {
      console.log('API响应数据:', response.data);
      return response.data;
    })
    .catch(error => {
      console.error('请求失败:', error);
      throw error; // 将错误传递给调用方
    });
}



